<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--服务商管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <!-------------开关按钮css-------------->
    <link rel="stylesheet" href="__STATIC_URL__/static/css/bootstrapSwitch.css">
    <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <link rel="stylesheet" href="__STATIC_URL__/static/css/addmchat.css"/>
    <script src="__STATIC_URL__/static/jquery/2.2.1/jquery.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/js/bootstrapSwitch.js"></script>
    <script src="__STATIC_URL__/static/js/commen.js" type="text/javascript" charset="utf-8"></script>
    <script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=KNPBZ-RXKWI-SJJGI-5S3HH-AGDS6-Q6BDW"></script>
    <!--<script src="__STATIC_URL__/static/js/liandong.js"></script>-->
    <script src="__STATIC_URL__/static/layer/layer.js"></script>
    <script src="__STATIC_URL__/static/js/area.js"></script>

    <script>
        //调用poi类信接口
        function clearOverlays(overlays) {
            var overlay;
            while (overlay = overlays.pop()) {
                overlay.setMap(null);
            }
        }
        function geolocation_localcity(id) {
            //console.log(132146);
            var objS  = document.getElementById(id);
            var index=objS.selectedIndex ;
            localcity = objS.options[index].value;

            // console.log(11,localcity);
            clearOverlays(markers);
            searchService.search(localcity);
            //citylocation.searchCityByName(localcity);

        }
        function searchKeyword() {
            var localcity = document.getElementById("keyword").value;
            // console.log(localcity);
            clearOverlays(markers);
            searchService.search(localcity);
            //citylocation.searchCityByName(localcity);


        }

        $(function(){
            locat()
        })
        function locat(){
            var data=[];
            $.ajax({
                url: "{:url('momachtest/getIpWsLocation')}",
                type: 'post',
                async: true,
                data: {},
                success: function (data) {
                    // console.log(22,data);
                    var data=data.location;
                    init(data)
                }
            })
            //console.log(data);
        }
        var searchService,geocoder,citylocation,map,markers = [];
        var init = function() {
            var center = new qq.maps.LatLng(36.067972, 113.837242);
            map = new qq.maps.Map(document.getElementById('container'), {
                center: center,
                zoom: 13,
                panControl : true,
                zoomControl : true,
                zoomControlOptions : {
                    style : qq.maps.ZoomControlStyle.SMALL
                }
            });
            var latlngBounds = new qq.maps.LatLngBounds();
            //调用Poi检索类
            searchService = new qq.maps.SearchService({
                complete : function(results){
                    var pois = results.detail.pois;
                    // console.log(36,pois);
                    for(var i = 0,l = pois.length;i < l; i++){
                        var poi = pois[i];
                        latlngBounds.extend(poi.latLng);
                        var marker = new qq.maps.Marker({
                            map:map,
                            position: poi.latLng
                        });
                        marker.setTitle(i+1);
                        markers.push(marker);
                    }
                    map.fitBounds(latlngBounds);
                }
            });
            var marker = new qq.maps.Marker( {
                map : map,
                position : center
            });

            var infoWin = new qq.maps.InfoWindow( {
                map : map
            });
            qq.maps.event.addListener(
                map,
                'click',
                function(event) {
                    $("#latitude").val(event.latLng.getLat());
                    $("#longitude").val(event.latLng.getLng());
                    $.ajax({
                        url:"{:url('momach/getaddress')}",
                        type:'post',
                        async: true,
                        data:{
                            lat:event.latLng.getLat(),
                            lng:event.latLng.getLng()
                        },
                        success:function(data){
                            infoWin.open();
                            infoWin.setContent('<div style="text-align:center;white-space:nowrap;margin:10px;">'+data.address+'</div>');
                            infoWin.setPosition(event.latLng);
                            $("#address").val(data.address);
                            $("#province").val(data.address_component.province);
                            $("#city").val(data.address_component.city);
                            $("#district").val(data.address_component.district);
                            $("#street").val(data.address_component.street);
                            $("#street_number").val(data.address_component.street_number);
                        },
                        error:function(){
                            alert("获取地址失败");
                        }
                    })
                }
            );
        }
    </script>
    <style>
        .layui-laydate {

            z-index: 6666666 !important;

        }
    </style>
</head>
<body >
{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>
                    当前位置是&nbsp;:&nbsp;商户管理
                </li>
                <li class="active" style="color: #02b87f;"> 添加商户</li>
            </ul>
        </div>
        <div class="panel panel-default mgl15 mgr15">
            <div class="panel-heading addCharts" style="background:#ededed;">添加商户</div>
            <div class="panel-body">
                <form class="form-horizontal adminex-form" action="" method="post" id="mach" name="form" enctype="multipart/form-data" >
                    <ul id="myTab" class="nav nav-tabs">
                        <li class="active"><a href="#jichu" data-toggle="tab">基础信息</a></li>
                        <li><a href="#weihu" data-toggle="tab">支付信息</a></li>
                    </ul>
                    <div id="myTabContent" class="tab-content" style="padding-top:15px;">
                        <div class="tab-pane fade in active" id="jichu">
                            <div class="form-group" id="ferror1">
                                <label class="col-sm-2 col-sm-2 control-label">商户名称：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="merchant" name="merchant_name">
                                    <div id="error1" class="error"></div>
                                </div>
                            </div>
                            <div class="form-group" id="ferror11">
                                <label class="col-sm-2 col-sm-2 control-label">商户类型：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <select name="momach_type" class="form-control ipt4" id="momach_type" required>

                                        <!--<option value="1">系统公众号</option>-->
                                        <option value="0">卡券</option>
                                        <option value="1">支付</option>
                                    </select>
                                    <div class="text-danger" style="color:#808080">支付类型的商户无需拥有认证服务号，可使用支付功能。</div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">商户LOGO：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="file" id="exampleInputFile" name="img" onchange="publicUpload('exampleInputFile')">
                                    <input type="hidden" value="" name="img" class="exampleInputFile-ipt" id="img">
                                    <img src="" class="exampleInputFile-src hide" alt="" style="width:150px;height: 150px;margin: 15px auto;float: left;">
                                    <div id="error10" class="error"></div>
                                </div>
                            </div>

                            <div class="form-group" id="ferror3">
                                <label class="col-sm-2 col-sm-2 control-label">商户联系人：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="contacts" name="contacts">
                                    <div id="error3" class="error"></div>
                                </div>
                            </div>
                            <div class="form-group" id="">
                                <label class="col-sm-2 col-sm-2 control-label">商户账号：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="username" name="username">
                                    <div id="error1" class="error"></div>
                                </div>
                            </div>
                            <div class="form-group" id="">
                                <label class="col-sm-2 col-sm-2 control-label">登录密码：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="password" name="password">
                                    <div id="error1" class="error"></div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">选择通知公众号<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-9 col-xs-12">
                                    <select name="tpl_msg_type" class="form-control ipt4" id="tpl_msg_type" required>

                                        <!--<option value="1">系统公众号</option>-->
                                        <option value="2">代理商公众号</option>
                                        <option value="3">商户公众号</option>
                                    </select>
                                    <div class="text-danger">选择的公众号为收银报表通知发送的公众号</div>
                                </div>
                            </div>
                            <div class="form-group" id="ferror1">
                                <label class="col-sm-2 col-sm-2 control-label">可开门店数量：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="mc_number" value="10" name="mc_number">
                                    <div id="error1" class="error"></div>
                                </div>
                            </div>
                            <div class="form-group" >
                                <label class="col-sm-2 col-sm-2 control-label">开户时间<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" name="start_time" class="form-control ipt4" value="{$time['starttime']}" placeholder="请选择开始时间" readonly="readonly" id="starttime">
                                </div>
                            </div>
                            <div class="form-group" >
                                <label class="col-sm-2 col-sm-2 control-label">到期时间<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" name="end_time" class="form-control ipt4" value="{$time['endtime']}" placeholder="请选择到期时间" readonly="readonly" id="endtime">
                                </div>
                            </div>
                            <div class="form-group" id="ferror4">
                                <label class="col-sm-2 col-sm-2 control-label">商户电话：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" id="tel" name="tel">
                                    <div id="error4" class="error"></div>
                                </div>
                            </div>
                            <!--地图坐标-->
                            <div class="form-group hide">
                                <label class="col-sm-2 col-sm-2 control-label">坐标系：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <select name="offset_type" class="form-control border-no">
                                        <option value="1">火星坐标</option>
                                        <option value="2">SOGOU经纬度</option>
                                        <option value="3">为百度经纬度</option>
                                        <option value="4">mapbar经纬度</option>
                                        <option value="5">为GPS坐标</option>
                                        <option value="6">SOGOU墨卡托坐标</option>
                                    </select>
                                    <div class="error"></div>
                                </div>
                            </div>

                            <div class="form-group hide">
                                <label class="col-sm-2 col-sm-2 control-label">地理位置经度：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="longitude" name='longitude' placeholder="火星坐标">
                                    <div class="error"></div>
                                </div>
                            </div>

                            <div class="form-group hide">
                                <label class="col-sm-2 col-sm-2 control-label">地理位置纬度：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="latitude" name='latitude' placeholder="火星坐标">
                                    <div class="error"></div>
                                </div>
                            </div>
                            <div class="form-group" id="area">
                                <label class="col-sm-2 col-sm-2 control-label">地区：</label>
                                <div class="col-sm-4">
                                    <div class="input-group">
                                        <select class="form-control" id="s_province" name="" onclick="geolocation_localcity('s_province')">

                                        </select>
                                        <div class="input-group-addon">-</div>
                                        <select class="form-control" name="" id="s_city" onclick="geolocation_localcity('s_city')">

                                        </select>
                                        <div class="input-group-addon">-</div>
                                        <select class="form-control" name="" id="s_county" onclick="geolocation_localcity('s_county')">

                                        </select>
                                        <div id="error13" class="error"></div>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">搜索地点：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input id="keyword" type="textbox" class="form-control ipt4" oninput="searchKeyword()" placeholder="在下方地图上单击地址完成选择">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">选取地址：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <div id="container" style="height:500px;width: 80%;"></div>
                                </div>
                            </div>

                            <div class="error"></div>
                            <!--地图-end-->
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">商户地址：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-10">
                                    <input type="hidden" id="province" name="province">
                                    <input type="hidden" id="city" name="city">
                                    <input type="hidden" id="district" name="district">
                                    <input type="hidden" id="street" name="street">
                                    <input type="hidden" id="street_number" name="street_number">
                                    <input type="text" class="form-control ipt6" id="address" name="address">
                                    <div id="error5" class="error"></div>
                                </div>
                            </div>
                            <div class="form-group" id="levelst">
                                <label class="col-sm-2 col-sm-2 control-label">行业：<span class="glyphicon glyphicon-asterisk glyphicon-tip"></span></label>
                                <div class="col-sm-6">
                                    <div class="input-group">
                                        <select class="form-control" id="primary" name="leibie" onchange="second_lb(this)">

                                            <option value="">请选择</option>
                                            {volist name="cate" id="vo"}
                                            <option value="{$vo['name']}" data-id="{$vo['id']}">{$vo['name']}</option>
                                            {/volist}
                                        </select>
                                        <div class="input-group-addon">-</div>
                                        <select class="form-control" name="leibie2" id="secondary">
                                            <option value="">请选择</option>
                                        </select>
                                        <div id="error11" class="error"></div>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">代理商：</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control ipt4" readonly id="agent" name="agent" value="{$agents.name}">
                                    <div  class="error"></div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">业务员：</label>
                                <div class="col-sm-10">
                                    <select class="form-control" style="width: 40%;" id="salesman" name="salesman" >
                                        {volist name="sales" id="vo"}
                                        <option value="{$vo.id}">{$vo.username}</option>
                                        {/volist}
                                    </select>
                                    <div  class="error"></div>
                                </div>
                            </div>
                            <div class="form-group" style="height: 32px;">
                                <label class="col-sm-2 col-sm-2 control-label">商户通知设定：</label>
                                <div class="col-sm-10">
                                    <div class="switch switch-small" data-animated="true" id="tz_setting">
                                        <input type="checkbox" name="tz_setting" value="1" class="tz_setting" checked/>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 col-sm-2 control-label">是否开启刷卡支付：</label>
                                <div class="col-sm-10">
                                    <div class="switch switch-small" data-animated="true" id="is_cartpay">
                                        <input type="checkbox" name="is_cartpay" value="1" class="is_cartpay" checked/>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="tab-pane fade" id="weihu">
                            <div class="form-group" style=" border-bottom: none;   ">
                                <label class="col-sm-1 col-sm-1 control-label" style=" text-align:left; ">当前通道：</label>
                                <input type="hidden" id="tongdao" value="0" name="shtd">
                                <label type="text" id="xuan"  class="ipt4 control-label" style="width:150px;    text-align: left;" >官方通道</label>
                                <a href="javascript:;" data-toggle="modal" data-target="#myModal1" class="col-sm-1 btn-link" style="float: none; display: inline-block;margin-top: 6px;margin-left:5px;font-size:13px;">选择</a>
                            </div>
                            <ul id="myTab1" class="nav nav-tabs">
                                <li class="active">
                                    <a href="#tab_weixin" data-toggle="tab">微信通道</a>
                                </li>
                                <li>
                                    <a href="#tab_zfb" data-toggle="tab">支付宝通道</a>
                                </li>
                                <li>
                                    <a href="#tab_bank" data-toggle="tab">网商通道</a>
                                </li>
                            </ul>
                            <div id="myTabContent1" class="tab-content" style="padding-top:15px;">
                                <div class="tab-pane fade in active" id="tab_weixin">
                                    <div class="form-group" id="ferror2">
                                        <label class="col-sm-2 col-sm-2 control-label">微信商户号：</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="sub_mch_id" name="sub_mch_id" class="form-control ipt4">
                                            <div id="error2" class="error"></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="tab_zfb">
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">授权Token：</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="ali_merid" name="ali_merid" class="form-control ipt4">

                                            <div class="error"></div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">口碑商户ID：</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="ali_store_id" name="ali_store_id" class="form-control ipt4">
                                            <div class="error"></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="tab-pane fade" id="tab_bank">
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">商户门店ID</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="lft_merchant_no" name="lft_merchant_no" class="form-control ipt4">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">商户ID</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="lft_core_merchant_no" name="lft_core_merchant_no" class="form-control ipt4">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">商户pid</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="lft_pid" name="lft_pid" class="form-control ipt4">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="col-sm-2 col-sm-2 control-label">商户key</label>
                                        <div class="col-sm-10">
                                            <input type="text" id="lft_key" name="lft_key" class="form-control ipt4">
                                        </div>
                                    </div>
                                </div>
                            </div>


                            <!--<div class="form-group">-->
                            <!--<label class="col-sm-2 col-sm-2 control-label">民生银行商户号：</label>-->
                            <!--<div class="col-sm-10">-->
                            <input type="hidden" id="cmmb_mer_id" name="cmmb_mer_id" class="form-control ipt4">
                            <!--<div class="error"></div>-->
                            <!--</div>-->
                            <!--</div>-->



                            <div id="isdiyset" class="hidden">

                            </div>
                        </div>
                    </div>
                    <div style="text-align: center">
                        <button type="button" onclick="addform()" class="btn btn-primary">添加商户</button>
                    </div>
                </form>
            </div>
        </div>
        {include file='public/footer'/}
    </div>

</section>
<div class="modal fade" id="myModal1" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel1">选择通道</h4>
            </div>
            <div class="modal-body">
                <div class="form-group" style="height:150px;">
                    <label class="col-sm-2 col-sm-2 control-label" style="    margin-top: 10px;">选择通道：</label>
                    <div class="col-sm-5 col-sm-5">
                        <div class="radio">
                            <label >
                                <input type="radio" name="shtd" id="optionsRadios3" value="0" checked >官方通道
                            </label>
                        </div>
                        <div class="radio">
                            <label >
                                <input type="radio" name="shtd" id="optionsRadios4" value="10" >网商通道
                            </label>
                        </div>
                        <div class="radio">
                            <label >
                                <input type="radio" name="shtd"  id="optionsRadios5" value="2" >官方无会员卡支付通道
                            </label>
                        </div>
                    </div>

                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="xuanz()">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>


    <script>
    function xuanz(){
        var shtd= parseInt($('input[name="shtd"]:checked ').val());
        // console.log(12132,shtd);
        $("#tongdao").val(shtd);
        if(shtd==2){
            $("#xuan").html("官方无会员卡支付通道 ");
        }else if(shtd==10){
            $("#xuan").html("网商通道");

        }else {
            $("#xuan").html("官方通道");

        }
        $("#myModal1").modal('hide');
    }

</script>
<script>
    function xuanz(){
        var shtd= parseInt($('input[name="shtd"]:checked ').val());
        // console.log(12132,shtd);
        $("#tongdao").val(shtd);
        if(shtd==2){
            $("#xuan").html("官方无会员卡支付通道 ");
        }else if(shtd==10){
            $("#xuan").html("网商通道");

        }else {
            $("#xuan").html("官方通道");

        }
        $("#myModal1").modal('hide');
    }
</script>
<script>

    $(function(){

        _init_area();
    })
</script>
<script>
    function second_lb(obj){
        var seval=  $(obj).find("option:selected").attr("data-id");
        // console.log(seval);
        $.ajax({
            url: "{:url('momach/getsubcate')}",
            type: "post",
            data: {
                id: seval
            },
            success: function (data) {
                // console.log(11,data);
                if (data.code == 0) {
                    var data=data.data;
                    var list="";
                    for(var i=0;i<data.length;i++){

                        list+="<option value='" +data[i].name+"'>" +data[i].name+"</option>";
                    }
                    $("#secondary").html(list);
                }
            }
        })
    }
</script>
<script type="text/javascript">
    // 地区
    var Gid  = document.getElementById ;

    var showArea = function(){

        Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" +

            Gid('s_city').value + " - 县/区" +

            Gid('s_county').value + "</h3>"

    }

    Gid('s_county').setAttribute('onchange','showArea()');

</script>
<script src="__STATIC_URL__/static/laydate/laydate.js"></script>




<script>
    laydate.render({
        elem: '#starttime',
        type: 'datetime',
        change: function(value, date,endDate){
            // console.log(value,date);
            var endtime = $("#endtime").val();

            //转换时间
            var endtime=new Date(endtime.replace("-", "/").replace("-", "/")).getTime();
            var starttime=new Date(value.replace("-", "/").replace("-", "/")).getTime();
            //比较时间
            // console.log(11,endtime,starttime);

            if(endtime <= starttime){
                layer.alert("开始时间不可以大于结束时间");
                $("#starttime").val("");
            }
        }
    });
    laydate.render({
        elem: '#endtime',
        type: 'datetime',
        change: function(value, date,endDate){
            // console.log(value,date);
            var starttime = $("#starttime").val();

//转换时间
            var start=new Date(starttime.replace("-", "/").replace("-", "/")).getTime();
            var end=new Date(value.replace("-", "/").replace("-", "/")).getTime();
//比较时间
//             console.log(11,start,end);

            if(end <= start){
                layer.alert("结束时间不可以小于开始时间");
                $("#endtime").val("");
            }
        }
    });
</script>

<script type="text/javascript">
    function publicUpload(file) {
        var formData = new FormData();
        formData.append('file', $('#' + file)[0].files[0]);
        formData.append('other',file);
        $.ajax({
            url: "{:url('uploads/machuploads')}",
            type: 'POST',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
        }).done(function (res) {
            // console.log(res);
            $(".exampleInputFile-src").attr("src",res.pic).removeClass("hide");
            $(".exampleInputFile-ipt").val(res.pic);
        }).fail(function (res) {
            alert("上传失败")
        });
    }


</script>
<script>
    function addform() {
        $('#ferror1').removeClass('has-error');
        $('#ferror3').removeClass('has-error');
        $('#ferror4').removeClass('has-error');
        $('#ferror5').removeClass('has-error');
        $('#ferror7').removeClass('has-error');
        $('#ferror9').removeClass('has-error');
        $('#ferror10').removeClass('has-error');
        $('#error1').text('');
        $('#error2').text('');
        $('#error3').text('');
        $('#error4').text('');
        $('#error5').text('');
        $('#error7').text('');
        $('#error9').text('');
        $('#error10').text('');
        $('#error11').text('');
        var merchant = $('#merchant').val();
        var sub_mch_id = $('#sub_mch_id').val();
        var contacts = $('#contacts').val();
        var tel = $('#tel').val();
        var address = $('#address').val();
        var agent = $('#agent').val();
        var merid = $("#ali_merid").val();
        var username = $("#username").val();
        var password = $("#password").val();
        /*logo*/
        var img = $("#img").val();
        /*类别*/
        var primary = $("#primary").val();
        var secondary = $("#secondary").val();
        /*开户时间*/
        var starttime = $("#starttime").val();
        /*开户时间*/
        var endtime = $("#endtime").val();
        /*通道*/
       var shtd= parseInt($('input[name="shtd"]:checked ').val());
       var lft_merchant_no=$("#lft_merchant_no").val();
       var lft_core_merchant_no=$("#lft_core_merchant_no").val();
       var lft_pid=$("#lft_pid").val();
       var lft_key=$("#lft_key").val();
       // console.log(222,shtd);
        if (merchant === '') {
            $('#myTab a[href="#jichu"]').tab('show')
            $('#ferror1').addClass('has-error');
            $('#error1').text('商户名称不能为空');
            $('#merchant').focus();
            return;
        }
        if (img === '') {
            layer.alert("商户logo不能为空");
            return;
        }
        if (contacts == '') {
            $('#myTab a[href="#jichu"]').tab('show')
            $('#ferror3').addClass('has-error');
            $('#error3').text('商户联系人不能为空');
            $('#contacts').focus();
            return;
        }
        if (username == '') {
            $('#myTab a[href="#jichu"]').tab('show')
            layer.alert("商户帐号不能为空");
            return;
        }
        if (password == '') {
            $('#myTab a[href="#jichu"]').tab('show')
            layer.alert("商户登录密码不能为空");
            return;
        }
        if (starttime == '') {

            layer.alert("商户开户时间不能为空");
            return;
        }
        if (endtime == '') {

            layer.alert("商户到期时间不能为空");
            return;
        }
        if (tel == '') {
            $('#myTab a[href="#jichu"]').tab('show')
            $('#ferror4').addClass('has-error');
            $('#error4').text('商户联系电话不能为空');
            $('#tel').focus();
            return;
        }
        if (address == '') {
            $('#myTab a[href="#jichu"]').tab('show')
            $('#ferror5').addClass('has-error');
            $('#error5').text('商户地址不能为空');
            $('#address').focus();
            return;
        }

        if (primary == '请选择') {
            $('#myTab a[href="#jichu"]').tab('show')
            layer.alert("行业不能为空");
            return;
        }
        if (secondary == '请选择') {
            $('#myTab a[href="#jichu"]').tab('show')
            layer.alert("行业不能为空");
            return;
        }
        if (shtd == 10) {
             if(lft_merchant_no==""){
                 layer.alert("商户门店ID不能为空");
                 return;
             }
            if(lft_core_merchant_no==""){
                layer.alert("商户ID不能为空");
                return;
            }
            if(lft_pid==""){
                layer.alert("商户pid不能为空");
                return;
            }
            if(lft_key==""){
                layer.alert("商户key不能为空");
                return;
            }
        }
        $('#mach').submit();
    }
    $(function(){
//        获取类别

        $("#tz_setting").on('switch-change',function (e, data) {
            var $el = $(data.el),value = data.value;
            if(value==true){
                $(".tz_setting").val(1);
            }else if(value==false){
                $(".tz_setting").val(0);
            }
        });
        $("#is_cartpay").on('switch-change',function (e, data) {
            var $el = $(data.el),value = data.value;
            if(value==true){
                $(".is_cartpay").val(1);
            }else if(value==false){
                $(".is_cartpay").val(0);
            }
        });
        $("#is_store").on('switch-change',function (e, data) {
            var $el = $(data.el),value = data.value;
            if(value==true){
                $(".is_store").val(1);
            }else if(value==false){
                $(".is_store").val(0);
            }
        });
    })
</script>
</body>

</html>
